package com.cwj.thread;

/**
 * @author chenwujie
 * @date 2021-01-26 11:09
 */
public class YieldTest {
    public static void main(String[] args) {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                String name = Thread.currentThread().getName();
                for (int i = 0; i < 100; i++) {
                    System.out.println(name + "--" +i);
                    if(i%10 == 0){
                        Thread.yield();
                    }
                }
            }
        };
        Thread thread = new Thread(runnable);
        Thread thread2 = new Thread(runnable);

        thread.start();
        thread2.start();
    }
}
